package com.woniuxy.student.consumer;

import com.rabbitmq.client.Channel;
import com.woniuxy.commons.entity.wyh.DivideClasses;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Date;

/**
 * @Author weizihan
 * @Date 2020/7/22 2020/7/22
 * @Description 死信消费者
 * @Since version-1.0
 */
@Component
public class DeadComsumer {
    @RabbitListener(queues = "deadQueue")
    public void deadReceived(DivideClasses DivideClasses, Message message, Channel channel) throws IOException {
        System.out.println("死信接受到消息"+DivideClasses+new Date());
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
